package com.ruoyi.workflow.controller;

import java.util.List;

import com.ruoyi.workflow.domain.WorkflowMission;
import com.ruoyi.workflow.service.IWorkflowMissionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定期工作管理Controller
 * 
 * @author ruoyi
 * @date 2023-02-13
 */
@RestController
@RequestMapping("/system/mission")
public class WorkflowMissionController extends BaseController
{
    @Autowired
    private IWorkflowMissionService workflowMissionService;

    /**
     * 查询定期工作管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mission:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkflowMission workflowMission)
    {
        startPage();
        List<WorkflowMission> list = workflowMissionService.selectWorkflowMissionList(workflowMission);
        return getDataTable(list);
    }

    /**
     * 导出定期工作管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mission:export')")
    @Log(title = "定期工作管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkflowMission workflowMission)
    {
        List<WorkflowMission> list = workflowMissionService.selectWorkflowMissionList(workflowMission);
        ExcelUtil<WorkflowMission> util = new ExcelUtil<WorkflowMission>(WorkflowMission.class);
        return util.exportExcel(list, "mission");
    }

    /**
     * 获取定期工作管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(workflowMissionService.selectWorkflowMissionById(id));
    }

    /**
     * 新增定期工作管理
     */
    @Log(title = "定期工作管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkflowMission workflowMission)
    {
        return toAjax(workflowMissionService.insertWorkflowMission(workflowMission));
    }

    /**
     * 修改定期工作管理
     */
    @PreAuthorize("@ss.hasPermi('system:mission:edit')")
    @Log(title = "定期工作管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkflowMission workflowMission)
    {
        return toAjax(workflowMissionService.updateWorkflowMission(workflowMission));
    }

    /**
     * 删除定期工作管理
     */
    @PreAuthorize("@ss.hasPermi('system:mission:remove')")
    @Log(title = "定期工作管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workflowMissionService.deleteWorkflowMissionByIds(ids));
    }
}
